#ifndef _DATASET_HPP
#define _DATASET_HPP
#include <Eigen/Dense>
#include <string>
#include <vector>
#include <fstream>
#include <sstream>
using std::vector;
using std::string;
using namespace Eigen;

//for comparing the row-th feature value
template <typename T>
struct ColComparator
{
	const MatrixBase<T>& matrix;
	const int row;
	ColComparator(MatrixBase<T>& m, int row)
		:matrix(m.derived()),row(row)
	{
	}
	bool operator()(int i, int j) const
	{
		return matrix(row, i) < matrix(row, j);
	}
};

class DataCollector
{
public:
	DataCollector();
	DataCollector(const DataCollector&);
	DataCollector &operator=(const DataCollector&);
	virtual ~DataCollector();

	void readDataFromFile(const string& fileName);
	//ColLabeledData *subDataList(int start,int len) const;
	//void shuffle();

	MatrixXd * DataList() const { return dataList; }
	void sortByCol(int row) const;
	void premuteByCol() const;
private:
	MatrixXd *dataList;
};


inline DataCollector::DataCollector()
	:dataList(nullptr)
{
}
inline DataCollector::DataCollector(const DataCollector& right)
{
	dataList = new MatrixXd(*right.dataList);
}
inline DataCollector &DataCollector::operator=(const DataCollector& right)
{
	delete(dataList);
	dataList = new MatrixXd(*right.dataList);
	return *this;
}


inline DataCollector::~DataCollector()
{
	delete(dataList);
}


#endif
